package com.punch.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.punch.common.vo.user.user.UserExtendVO;
import com.punch.user.mapper.SysUserSchoolMapper;
import com.punch.user.model.SysUserSchool;
import com.punch.user.service.UserSchoolService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * UserSchoolServiceImpl-学校结算信息
 *
 * @author wujj
 * @version 1.0.0
 * @since 2020/9/14 10:35
 */
@Service
public class UserSchoolServiceImpl extends ServiceImpl<SysUserSchoolMapper, SysUserSchool> implements UserSchoolService {

    /**
     * 获取学校结算信息
     *
     * @param userId 用户uid
     * @return UserExtendVO
     */
    @Override
    public UserExtendVO getUserSettlement(Long userId) {
        QueryWrapper<SysUserSchool> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(SysUserSchool::getUserId, userId);
        SysUserSchool sysUserSchool = getOne(queryWrapper);
        UserExtendVO userExtendVO = new UserExtendVO();
        BeanUtils.copyProperties(sysUserSchool, userExtendVO);
        return userExtendVO;
    }
}